package vivek.project.pocketmoney.expenses.model
{
	import vivek.project.pocketmoney.admin.model.AdminConstants;
	import vivek.project.pocketmoney.common.utils.StringUtils;

	public class IDBIBankLoader extends AccountLoaderImpl
	{
		private static var iciciBankLoader:IDBIBankLoader=null;

		private const delimiter:String="\t";

		private const numCols:int=7;

		private const dataStart:int=10;

		private const bankName:String="IDBI";

		public function IDBIBankLoader()
		{
			dateFormat="DD/MM/YY";
			categoryMatch.push({matchString: "int", catid: 29});
			categoryMatch.push({matchString: "IP AMT", catid: 9});
		}

		public static function getInstance():IDBIBankLoader
		{
			if (iciciBankLoader == null)
				iciciBankLoader=new IDBIBankLoader();
			return iciciBankLoader;
		}

		override public function checkValiditiy(fileContent:String):Boolean
		{
			return false;
		}

		override public function getExpenseRecords(fileContent:String, account:Object):Array
		{
			var txnrecords:Array;
			var txntype:int=AdminConstants.WITHDRAWAL;
			var amount:Number=0;
			txnrecords=loadExpenseData(fileContent, delimiter, numCols);
			var expenseRecords:Array=new Array();
			for each (var obj:Object in txnrecords)
			{
				if (StringUtils.trimSpecialChar(obj[4]) == "DR")
					txntype=AdminConstants.WITHDRAWAL;
				else
					txntype=AdminConstants.DEPOSIT;
				try
				{
					var expenseRecord:Object=new Object();
					amount=new Number(StringUtils.trimSpecialChar(obj[5]));
					//(date:String, amount:Number, memo:String, txnType:int, account:int, category:int, instr:String):Object
					expenseRecord=createExpenseObject(obj[0], amount, obj[2], txntype, account.am_accountid, 24, obj[2]);
					expenseRecords.push(expenseRecord);
				}
				catch (error:Error)
				{
				}
			}
			return expenseRecords;
		}
	}
}